{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e66662c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b9895d0b",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<ipython-input-2-d1680cea7f32>:5: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  df_hurun['价值（亿元人民币）'] = df_hurun['价值（亿元人民币）'].astype('int64')\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>排名变化</th>\n",
       "      <th>企业名称</th>\n",
       "      <th>价值（亿元人民币）</th>\n",
       "      <th>价值变化（亿元人民币）</th>\n",
       "      <th>国家</th>\n",
       "      <th>城市</th>\n",
       "      <th>行业</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>抖音</td>\n",
       "      <td>13400</td>\n",
       "      <td>-10050</td>\n",
       "      <td>中国</td>\n",
       "      <td>北京</td>\n",
       "      <td>社交媒体</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>SpaceX</td>\n",
       "      <td>8400</td>\n",
       "      <td>1680</td>\n",
       "      <td>美国</td>\n",
       "      <td>洛杉矶</td>\n",
       "      <td>航天</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>-1</td>\n",
       "      <td>蚂蚁集团</td>\n",
       "      <td>8000</td>\n",
       "      <td>-2010</td>\n",
       "      <td>中国</td>\n",
       "      <td>杭州</td>\n",
       "      <td>金融科技</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>Stripe</td>\n",
       "      <td>4100</td>\n",
       "      <td>-2210</td>\n",
       "      <td>美国</td>\n",
       "      <td>旧金山</td>\n",
       "      <td>金融科技</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5</td>\n",
       "      <td>11</td>\n",
       "      <td>Shein</td>\n",
       "      <td>4000</td>\n",
       "      <td>2680</td>\n",
       "      <td>中国</td>\n",
       "      <td>广州</td>\n",
       "      <td>电子商务</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>97</th>\n",
       "      <td>95</td>\n",
       "      <td>-16</td>\n",
       "      <td>Impossible 食品</td>\n",
       "      <td>470</td>\n",
       "      <td>0</td>\n",
       "      <td>美国</td>\n",
       "      <td>雷德伍德城</td>\n",
       "      <td>食品饮料</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98</th>\n",
       "      <td>95</td>\n",
       "      <td>-16</td>\n",
       "      <td>微医</td>\n",
       "      <td>470</td>\n",
       "      <td>0</td>\n",
       "      <td>中国</td>\n",
       "      <td>杭州</td>\n",
       "      <td>健康科技</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>99</th>\n",
       "      <td>99</td>\n",
       "      <td>58</td>\n",
       "      <td>蜂巢能源</td>\n",
       "      <td>460</td>\n",
       "      <td>190</td>\n",
       "      <td>中国</td>\n",
       "      <td>常州</td>\n",
       "      <td>新能源</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>100</th>\n",
       "      <td>99</td>\n",
       "      <td>-6</td>\n",
       "      <td>Better.com</td>\n",
       "      <td>460</td>\n",
       "      <td>60</td>\n",
       "      <td>美国</td>\n",
       "      <td>纽约</td>\n",
       "      <td>金融科技</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>101</th>\n",
       "      <td>99</td>\n",
       "      <td>-20</td>\n",
       "      <td>Automation Anywhere</td>\n",
       "      <td>460</td>\n",
       "      <td>-10</td>\n",
       "      <td>美国</td>\n",
       "      <td>圣何塞</td>\n",
       "      <td>人工智能</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>101 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     排名 排名变化                 企业名称  价值（亿元人民币） 价值变化（亿元人民币）  国家     城市    行业\n",
       "1     1    0                   抖音      13400      -10050  中国     北京  社交媒体\n",
       "2     2    1               SpaceX       8400        1680  美国    洛杉矶    航天\n",
       "3     3   -1                 蚂蚁集团       8000       -2010  中国     杭州  金融科技\n",
       "4     4    0               Stripe       4100       -2210  美国    旧金山  金融科技\n",
       "5     5   11                Shein       4000        2680  中国     广州  电子商务\n",
       "..   ..  ...                  ...        ...         ...  ..    ...   ...\n",
       "97   95  -16        Impossible 食品        470           0  美国  雷德伍德城  食品饮料\n",
       "98   95  -16                   微医        470           0  中国     杭州  健康科技\n",
       "99   99   58                 蜂巢能源        460         190  中国     常州   新能源\n",
       "100  99   -6           Better.com        460          60  美国     纽约  金融科技\n",
       "101  99  -20  Automation Anywhere        460         -10  美国    圣何塞  人工智能\n",
       "\n",
       "[101 rows x 8 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hurun_独角兽 = pd.read_html('https://www.hurun.net/zh-CN/Info/Detail?num=L9SQPH9FKJB1')[-3]\n",
    "hurun_独角兽[0:1].values.tolist()[0]\n",
    "df_hurun = hurun_独角兽[1:]\n",
    "df_hurun.columns = hurun_独角兽[0:1].values.tolist()[0]\n",
    "df_hurun['价值（亿元人民币）'] = df_hurun['价值（亿元人民币）'].astype('int64')\n",
    "df_hurun"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "59a8fdd3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>行业</th>\n",
       "      <th>人工智能</th>\n",
       "      <th>企业服务</th>\n",
       "      <th>保险</th>\n",
       "      <th>健康科技</th>\n",
       "      <th>共享经济</th>\n",
       "      <th>分析</th>\n",
       "      <th>区块链</th>\n",
       "      <th>大数据</th>\n",
       "      <th>快递</th>\n",
       "      <th>教育科技</th>\n",
       "      <th>...</th>\n",
       "      <th>游戏</th>\n",
       "      <th>物流</th>\n",
       "      <th>生物科技</th>\n",
       "      <th>电子商务</th>\n",
       "      <th>社交媒体</th>\n",
       "      <th>网络安全</th>\n",
       "      <th>航天</th>\n",
       "      <th>软件服务</th>\n",
       "      <th>金融科技</th>\n",
       "      <th>食品饮料</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>国家</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>中国</th>\n",
       "      <td>570.0</td>\n",
       "      <td>515.0</td>\n",
       "      <td>740.0</td>\n",
       "      <td>1040.0</td>\n",
       "      <td>965.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>535.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1800.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4000.0</td>\n",
       "      <td>13400.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1300.0</td>\n",
       "      <td>8000.0</td>\n",
       "      <td>1000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>以色列</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>535.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>印度</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>480.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>720.0</td>\n",
       "      <td>1500.0</td>\n",
       "      <td>...</td>\n",
       "      <td>535.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>印度尼西亚</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>700.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1300.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>土耳其</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>800.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>墨西哥</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>580.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>巴哈马</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1300.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>德国</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>555.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>澳大利亚</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1750.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>瑞典</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>瑞士</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>575.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>美国</th>\n",
       "      <td>870.0</td>\n",
       "      <td>1170.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>840.0</td>\n",
       "      <td>1000.0</td>\n",
       "      <td>575.0</td>\n",
       "      <td>760.0</td>\n",
       "      <td>2500.0</td>\n",
       "      <td>1320.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>600.0</td>\n",
       "      <td>1200.0</td>\n",
       "      <td>800.0</td>\n",
       "      <td>840.0</td>\n",
       "      <td>1000.0</td>\n",
       "      <td>600.0</td>\n",
       "      <td>8400.0</td>\n",
       "      <td>750.0</td>\n",
       "      <td>4100.0</td>\n",
       "      <td>470.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>英国</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>700.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>570.0</td>\n",
       "      <td>1900.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>越南</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>韩国</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>535.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>560.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>马耳他</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>16 rows × 26 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "行业      人工智能    企业服务     保险    健康科技    共享经济     分析     区块链     大数据      快递  \\\n",
       "国家                                                                           \n",
       "中国     570.0   515.0  740.0  1040.0   965.0    NaN     NaN   535.0     NaN   \n",
       "以色列      NaN     NaN    NaN     NaN     NaN    NaN   535.0     NaN     NaN   \n",
       "印度       NaN     NaN    NaN     NaN   480.0    NaN     NaN     NaN   720.0   \n",
       "印度尼西亚    NaN     NaN    NaN     NaN   700.0    NaN     NaN     NaN     NaN   \n",
       "土耳其      NaN     NaN    NaN     NaN     NaN    NaN     NaN     NaN   800.0   \n",
       "墨西哥      NaN     NaN    NaN     NaN     NaN    NaN     NaN     NaN     NaN   \n",
       "巴哈马      NaN     NaN    NaN     NaN     NaN    NaN  1300.0     NaN     NaN   \n",
       "德国       NaN     NaN    NaN     NaN     NaN    NaN     NaN     NaN     NaN   \n",
       "澳大利亚     NaN     NaN    NaN     NaN     NaN    NaN     NaN     NaN     NaN   \n",
       "瑞典       NaN     NaN    NaN     NaN     NaN    NaN     NaN     NaN     NaN   \n",
       "瑞士       NaN     NaN    NaN     NaN     NaN    NaN   575.0     NaN     NaN   \n",
       "美国     870.0  1170.0    NaN   840.0  1000.0  575.0   760.0  2500.0  1320.0   \n",
       "英国       NaN     NaN    NaN     NaN     NaN    NaN   700.0     NaN     NaN   \n",
       "越南       NaN     NaN    NaN     NaN     NaN    NaN     NaN     NaN     NaN   \n",
       "韩国       NaN     NaN    NaN     NaN     NaN    NaN   535.0     NaN     NaN   \n",
       "马耳他      NaN     NaN    NaN     NaN     NaN    NaN  3000.0     NaN     NaN   \n",
       "\n",
       "行业       教育科技  ...     游戏      物流   生物科技    电子商务     社交媒体   网络安全      航天  \\\n",
       "国家             ...                                                         \n",
       "中国        NaN  ...    NaN  1800.0    NaN  4000.0  13400.0    NaN     NaN   \n",
       "以色列       NaN  ...    NaN     NaN    NaN     NaN      NaN    NaN     NaN   \n",
       "印度     1500.0  ...  535.0     NaN    NaN     NaN      NaN    NaN     NaN   \n",
       "印度尼西亚     NaN  ...    NaN     NaN    NaN  1300.0      NaN    NaN     NaN   \n",
       "土耳其       NaN  ...    NaN     NaN    NaN     NaN      NaN    NaN     NaN   \n",
       "墨西哥       NaN  ...    NaN     NaN    NaN   580.0      NaN    NaN     NaN   \n",
       "巴哈马       NaN  ...    NaN     NaN    NaN     NaN      NaN    NaN     NaN   \n",
       "德国        NaN  ...    NaN     NaN    NaN     NaN      NaN    NaN     NaN   \n",
       "澳大利亚      NaN  ...    NaN     NaN    NaN     NaN      NaN    NaN     NaN   \n",
       "瑞典        NaN  ...    NaN     NaN    NaN     NaN      NaN    NaN     NaN   \n",
       "瑞士        NaN  ...    NaN     NaN    NaN     NaN      NaN    NaN     NaN   \n",
       "美国        NaN  ...  600.0  1200.0  800.0   840.0   1000.0  600.0  8400.0   \n",
       "英国        NaN  ...    NaN     NaN    NaN     NaN      NaN    NaN     NaN   \n",
       "越南        NaN  ...    NaN     NaN    NaN     NaN      NaN    NaN     NaN   \n",
       "韩国        NaN  ...    NaN     NaN    NaN   560.0      NaN    NaN     NaN   \n",
       "马耳他       NaN  ...    NaN     NaN    NaN     NaN      NaN    NaN     NaN   \n",
       "\n",
       "行业       软件服务    金融科技    食品饮料  \n",
       "国家                             \n",
       "中国     1300.0  8000.0  1000.0  \n",
       "以色列       NaN     NaN     NaN  \n",
       "印度        NaN     NaN     NaN  \n",
       "印度尼西亚     NaN     NaN     NaN  \n",
       "土耳其       NaN     NaN     NaN  \n",
       "墨西哥       NaN     NaN     NaN  \n",
       "巴哈马       NaN     NaN     NaN  \n",
       "德国      555.0     NaN     NaN  \n",
       "澳大利亚   1750.0     NaN     NaN  \n",
       "瑞典        NaN     NaN     NaN  \n",
       "瑞士        NaN     NaN     NaN  \n",
       "美国      750.0  4100.0   470.0  \n",
       "英国      570.0  1900.0     NaN  \n",
       "越南        NaN     NaN     NaN  \n",
       "韩国        NaN     NaN     NaN  \n",
       "马耳他       NaN     NaN     NaN  \n",
       "\n",
       "[16 rows x 26 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_hurun_pivot = df_hurun.pivot_table(index=\"国家\",columns=\"行业\",values= \"价值（亿元人民币）\",aggfunc=\"max\")\n",
    "df_hurun_pivot"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb1966b4",
   "metadata": {},
   "source": [
    "## 使用pyecharts生成图表"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "191af829",
   "metadata": {},
   "source": [
    "### 示例："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8a224cc8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting pyecharts\n",
      "  Downloading pyecharts-2.0.3-py3-none-any.whl (147 kB)\n",
      "Collecting simplejson\n",
      "  Downloading simplejson-3.19.1-cp38-cp38-win_amd64.whl (75 kB)\n",
      "Requirement already satisfied: jinja2 in c:\\users\\pc\\anaconda3\\lib\\site-packages (from pyecharts) (2.11.3)\n",
      "Collecting prettytable\n",
      "  Downloading prettytable-3.7.0-py3-none-any.whl (27 kB)\n",
      "Requirement already satisfied: MarkupSafe>=0.23 in c:\\users\\pc\\anaconda3\\lib\\site-packages (from jinja2->pyecharts) (1.1.1)\n",
      "Requirement already satisfied: wcwidth in c:\\users\\pc\\anaconda3\\lib\\site-packages (from prettytable->pyecharts) (0.2.5)\n",
      "Installing collected packages: simplejson, prettytable, pyecharts\n",
      "Successfully installed prettytable-3.7.0 pyecharts-2.0.3 simplejson-3.19.1\n"
     ]
    }
   ],
   "source": [
    "!pip install pyecharts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "12b50e3f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.0.3\n"
     ]
    }
   ],
   "source": [
    "import pyecharts\n",
    "print(pyecharts.__version__)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "95d4e64a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'D:\\\\0412\\\\render.html'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.charts import Bar\n",
    "\n",
    "bar = Bar()\n",
    "bar.add_xaxis([\"01\",\"02\",\"03\"])\n",
    "bar.add_yaxis(\"数量\",[20,56,54])\n",
    "bar.render()\n",
    "# 生成本地 HTML 文件"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7d976bbc",
   "metadata": {},
   "source": [
    "———————————————— 分 割 线 —————————————————"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58e4a6ee",
   "metadata": {},
   "source": [
    "### 使用模板："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "f64ffdc6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['河马', '蟒蛇', '老虎', '大象', '兔子', '熊猫', '狮子']"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Faker.choose()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "ec58877b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[77, 137, 23, 146, 90, 34, 94]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Faker.values()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "6ba1bfe9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/v5/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"c105b1b54c37479987370297c05ba032\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_c105b1b54c37479987370297c05ba032 = echarts.init(\n",
       "                    document.getElementById('c105b1b54c37479987370297c05ba032'), 'white', {renderer: 'canvas'});\n",
       "                var option_c105b1b54c37479987370297c05ba032 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5546\\u5bb6A\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                29,\n",
       "                140,\n",
       "                85,\n",
       "                77,\n",
       "                107,\n",
       "                69,\n",
       "                42\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stack\": \"stack1\",\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5546\\u5bb6B\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                129,\n",
       "                36,\n",
       "                93,\n",
       "                48,\n",
       "                134,\n",
       "                128,\n",
       "                75\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stack\": \"stack1\",\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5546\\u5bb6A\",\n",
       "                \"\\u5546\\u5bb6B\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u5c0f\\u7c73\",\n",
       "                \"\\u4e09\\u661f\",\n",
       "                \"\\u534e\\u4e3a\",\n",
       "                \"\\u82f9\\u679c\",\n",
       "                \"\\u9b45\\u65cf\",\n",
       "                \"VIVO\",\n",
       "                \"OPPO\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"text\": \"Bar-\\u5806\\u53e0\\u6570\\u636e\\uff08\\u5168\\u90e8\\uff09\",\n",
       "            \"target\": \"blank\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_c105b1b54c37479987370297c05ba032.setOption(option_c105b1b54c37479987370297c05ba032);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1e799274a30>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Bar\n",
    "from pyecharts.faker import Faker\n",
    "\n",
    "c = (\n",
    "    Bar()\n",
    "    .add_xaxis(Faker.choose())\n",
    "    .add_yaxis(\"商家A\", Faker.values(), stack=\"stack1\")\n",
    "    .add_yaxis(\"商家B\", Faker.values(), stack=\"stack1\")\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(is_show=False))\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"Bar-堆叠数据（全部）\"))\n",
    "    \n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a30d216",
   "metadata": {},
   "source": [
    "### ———————————— 分 割 线 ————————————"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a67a6640",
   "metadata": {},
   "source": [
    "## Bar柱状图可视化展示"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "530ee13d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['人工智能',\n",
       " '企业服务',\n",
       " '保险',\n",
       " '健康科技',\n",
       " '共享经济',\n",
       " '分析',\n",
       " '区块链',\n",
       " '大数据',\n",
       " '快递',\n",
       " '教育科技',\n",
       " '数字科技',\n",
       " '新能源',\n",
       " '新能源汽车',\n",
       " '新零售',\n",
       " '机器人',\n",
       " '消费品',\n",
       " '游戏',\n",
       " '物流',\n",
       " '生物科技',\n",
       " '电子商务',\n",
       " '社交媒体',\n",
       " '网络安全',\n",
       " '航天',\n",
       " '软件服务',\n",
       " '金融科技',\n",
       " '食品饮料']"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "行业 = df_hurun_pivot.columns.tolist()\n",
    "行业"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "b1f39cb7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[570.0,\n",
       " 515.0,\n",
       " 740.0,\n",
       " 1040.0,\n",
       " 965.0,\n",
       " nan,\n",
       " nan,\n",
       " 535.0,\n",
       " nan,\n",
       " nan,\n",
       " 2000.0,\n",
       " 670.0,\n",
       " 600.0,\n",
       " 670.0,\n",
       " 1200.0,\n",
       " nan,\n",
       " nan,\n",
       " 1800.0,\n",
       " nan,\n",
       " 4000.0,\n",
       " 13400.0,\n",
       " nan,\n",
       " nan,\n",
       " 1300.0,\n",
       " 8000.0,\n",
       " 1000.0]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "中国 = df_hurun_pivot.query('国家 == \"中国\"').values[0].tolist()\n",
    "中国"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "081843fb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[870.0,\n",
       " 1170.0,\n",
       " nan,\n",
       " 840.0,\n",
       " 1000.0,\n",
       " 575.0,\n",
       " 760.0,\n",
       " 2500.0,\n",
       " 1320.0,\n",
       " nan,\n",
       " nan,\n",
       " nan,\n",
       " nan,\n",
       " nan,\n",
       " 575.0,\n",
       " nan,\n",
       " 600.0,\n",
       " 1200.0,\n",
       " 800.0,\n",
       " 840.0,\n",
       " 1000.0,\n",
       " 600.0,\n",
       " 8400.0,\n",
       " 750.0,\n",
       " 4100.0,\n",
       " 470.0]"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "美国 = df_hurun_pivot.query('国家 == \"美国\"').values[0].tolist()\n",
    "美国"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "512fd093",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/v5/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"ed606f29a2c74542bacd134704ebf5ad\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_ed606f29a2c74542bacd134704ebf5ad = echarts.init(\n",
       "                    document.getElementById('ed606f29a2c74542bacd134704ebf5ad'), 'white', {renderer: 'canvas'});\n",
       "                var option_ed606f29a2c74542bacd134704ebf5ad = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e2d\\u56fd\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                570.0,\n",
       "                515.0,\n",
       "                740.0,\n",
       "                1040.0,\n",
       "                965.0,\n",
       "                null,\n",
       "                null,\n",
       "                535.0,\n",
       "                null,\n",
       "                null,\n",
       "                2000.0,\n",
       "                670.0,\n",
       "                600.0,\n",
       "                670.0,\n",
       "                1200.0,\n",
       "                null,\n",
       "                null,\n",
       "                1800.0,\n",
       "                null,\n",
       "                4000.0,\n",
       "                13400.0,\n",
       "                null,\n",
       "                null,\n",
       "                1300.0,\n",
       "                8000.0,\n",
       "                1000.0\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stack\": \"stack1\",\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u7f8e\\u56fd\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                870.0,\n",
       "                1170.0,\n",
       "                null,\n",
       "                840.0,\n",
       "                1000.0,\n",
       "                575.0,\n",
       "                760.0,\n",
       "                2500.0,\n",
       "                1320.0,\n",
       "                null,\n",
       "                null,\n",
       "                null,\n",
       "                null,\n",
       "                null,\n",
       "                575.0,\n",
       "                null,\n",
       "                600.0,\n",
       "                1200.0,\n",
       "                800.0,\n",
       "                840.0,\n",
       "                1000.0,\n",
       "                600.0,\n",
       "                8400.0,\n",
       "                750.0,\n",
       "                4100.0,\n",
       "                470.0\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stack\": \"stack1\",\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e2d\\u56fd\",\n",
       "                \"\\u7f8e\\u56fd\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u4eba\\u5de5\\u667a\\u80fd\",\n",
       "                \"\\u4f01\\u4e1a\\u670d\\u52a1\",\n",
       "                \"\\u4fdd\\u9669\",\n",
       "                \"\\u5065\\u5eb7\\u79d1\\u6280\",\n",
       "                \"\\u5171\\u4eab\\u7ecf\\u6d4e\",\n",
       "                \"\\u5206\\u6790\",\n",
       "                \"\\u533a\\u5757\\u94fe\",\n",
       "                \"\\u5927\\u6570\\u636e\",\n",
       "                \"\\u5feb\\u9012\",\n",
       "                \"\\u6559\\u80b2\\u79d1\\u6280\",\n",
       "                \"\\u6570\\u5b57\\u79d1\\u6280\",\n",
       "                \"\\u65b0\\u80fd\\u6e90\",\n",
       "                \"\\u65b0\\u80fd\\u6e90\\u6c7d\\u8f66\",\n",
       "                \"\\u65b0\\u96f6\\u552e\",\n",
       "                \"\\u673a\\u5668\\u4eba\",\n",
       "                \"\\u6d88\\u8d39\\u54c1\",\n",
       "                \"\\u6e38\\u620f\",\n",
       "                \"\\u7269\\u6d41\",\n",
       "                \"\\u751f\\u7269\\u79d1\\u6280\",\n",
       "                \"\\u7535\\u5b50\\u5546\\u52a1\",\n",
       "                \"\\u793e\\u4ea4\\u5a92\\u4f53\",\n",
       "                \"\\u7f51\\u7edc\\u5b89\\u5168\",\n",
       "                \"\\u822a\\u5929\",\n",
       "                \"\\u8f6f\\u4ef6\\u670d\\u52a1\",\n",
       "                \"\\u91d1\\u878d\\u79d1\\u6280\",\n",
       "                \"\\u98df\\u54c1\\u996e\\u6599\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"text\": \"Bar-\\u80e1\\u6da6TOP\\u72ec\\u89d2\\u517d\\u4e2d\\u7f8e\\u5bf9\\u6bd4\",\n",
       "            \"target\": \"blank\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"showDetail\": true,\n",
       "        \"showDataShadow\": true,\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_ed606f29a2c74542bacd134704ebf5ad.setOption(option_ed606f29a2c74542bacd134704ebf5ad);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1e79cce7130>"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Bar\n",
    "from pyecharts.faker import Faker\n",
    "\n",
    "c = (\n",
    "    Bar()\n",
    "    .add_xaxis(行业)\n",
    "    .add_yaxis(\"中国\", 中国, stack=\"stack1\")\n",
    "    .add_yaxis(\"美国\", 美国, stack=\"stack1\")\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(is_show=False))\n",
    "    .set_global_opts(\n",
    "        datazoom_opts=opts.DataZoomOpts(),\n",
    "        title_opts=opts.TitleOpts(title=\"Bar-胡润TOP独角兽中美对比\"))\n",
    "        \n",
    "    \n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a7db0263",
   "metadata": {},
   "source": [
    "## Pie饼状图可视化展示"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "351d001a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/v5/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"dbecc1bd791442dfa553dbc185206b13\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_dbecc1bd791442dfa553dbc185206b13 = echarts.init(\n",
       "                    document.getElementById('dbecc1bd791442dfa553dbc185206b13'), 'white', {renderer: 'canvas'});\n",
       "                var option_dbecc1bd791442dfa553dbc185206b13 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"blue\",\n",
       "        \"green\",\n",
       "        \"yellow\",\n",
       "        \"red\",\n",
       "        \"pink\",\n",
       "        \"orange\",\n",
       "        \"purple\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"colorBy\": \"data\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"selectedMode\": false,\n",
       "            \"selectedOffset\": 10,\n",
       "            \"clockwise\": true,\n",
       "            \"startAngle\": 90,\n",
       "            \"minAngle\": 0,\n",
       "            \"minShowLabelAngle\": 0,\n",
       "            \"avoidLabelOverlap\": true,\n",
       "            \"stillShowZeroSum\": true,\n",
       "            \"percentPrecision\": 2,\n",
       "            \"showEmptyCircle\": true,\n",
       "            \"emptyCircleStyle\": {\n",
       "                \"color\": \"lightgray\",\n",
       "                \"borderColor\": \"#000\",\n",
       "                \"borderWidth\": 0,\n",
       "                \"borderType\": \"solid\",\n",
       "                \"borderDashOffset\": 0,\n",
       "                \"borderCap\": \"butt\",\n",
       "                \"borderJoin\": \"bevel\",\n",
       "                \"borderMiterLimit\": 10,\n",
       "                \"opacity\": 1\n",
       "            },\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u4eba\\u5de5\\u667a\\u80fd\",\n",
       "                    \"value\": 570.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4f01\\u4e1a\\u670d\\u52a1\",\n",
       "                    \"value\": 515.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4fdd\\u9669\",\n",
       "                    \"value\": 740.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5065\\u5eb7\\u79d1\\u6280\",\n",
       "                    \"value\": 1040.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5171\\u4eab\\u7ecf\\u6d4e\",\n",
       "                    \"value\": 965.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5206\\u6790\",\n",
       "                    \"value\": null\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u533a\\u5757\\u94fe\",\n",
       "                    \"value\": null\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5927\\u6570\\u636e\",\n",
       "                    \"value\": 535.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5feb\\u9012\",\n",
       "                    \"value\": null\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6559\\u80b2\\u79d1\\u6280\",\n",
       "                    \"value\": null\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6570\\u5b57\\u79d1\\u6280\",\n",
       "                    \"value\": 2000.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u80fd\\u6e90\",\n",
       "                    \"value\": 670.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u80fd\\u6e90\\u6c7d\\u8f66\",\n",
       "                    \"value\": 600.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u96f6\\u552e\",\n",
       "                    \"value\": 670.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u673a\\u5668\\u4eba\",\n",
       "                    \"value\": 1200.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d88\\u8d39\\u54c1\",\n",
       "                    \"value\": null\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e38\\u620f\",\n",
       "                    \"value\": null\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7269\\u6d41\",\n",
       "                    \"value\": 1800.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u751f\\u7269\\u79d1\\u6280\",\n",
       "                    \"value\": null\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7535\\u5b50\\u5546\\u52a1\",\n",
       "                    \"value\": 4000.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u793e\\u4ea4\\u5a92\\u4f53\",\n",
       "                    \"value\": 13400.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7f51\\u7edc\\u5b89\\u5168\",\n",
       "                    \"value\": null\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u822a\\u5929\",\n",
       "                    \"value\": null\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8f6f\\u4ef6\\u670d\\u52a1\",\n",
       "                    \"value\": 1300.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91d1\\u878d\\u79d1\\u6280\",\n",
       "                    \"value\": 8000.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u98df\\u54c1\\u996e\\u6599\",\n",
       "                    \"value\": 1000.0\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {c}\"\n",
       "            },\n",
       "            \"labelLine\": {\n",
       "                \"show\": true,\n",
       "                \"showAbove\": false,\n",
       "                \"length\": 15,\n",
       "                \"length2\": 15,\n",
       "                \"smooth\": false,\n",
       "                \"minTurnAngle\": 90,\n",
       "                \"maxSurfaceAngle\": 90\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4eba\\u5de5\\u667a\\u80fd\",\n",
       "                \"\\u4f01\\u4e1a\\u670d\\u52a1\",\n",
       "                \"\\u4fdd\\u9669\",\n",
       "                \"\\u5065\\u5eb7\\u79d1\\u6280\",\n",
       "                \"\\u5171\\u4eab\\u7ecf\\u6d4e\",\n",
       "                \"\\u5206\\u6790\",\n",
       "                \"\\u533a\\u5757\\u94fe\",\n",
       "                \"\\u5927\\u6570\\u636e\",\n",
       "                \"\\u5feb\\u9012\",\n",
       "                \"\\u6559\\u80b2\\u79d1\\u6280\",\n",
       "                \"\\u6570\\u5b57\\u79d1\\u6280\",\n",
       "                \"\\u65b0\\u80fd\\u6e90\",\n",
       "                \"\\u65b0\\u80fd\\u6e90\\u6c7d\\u8f66\",\n",
       "                \"\\u65b0\\u96f6\\u552e\",\n",
       "                \"\\u673a\\u5668\\u4eba\",\n",
       "                \"\\u6d88\\u8d39\\u54c1\",\n",
       "                \"\\u6e38\\u620f\",\n",
       "                \"\\u7269\\u6d41\",\n",
       "                \"\\u751f\\u7269\\u79d1\\u6280\",\n",
       "                \"\\u7535\\u5b50\\u5546\\u52a1\",\n",
       "                \"\\u793e\\u4ea4\\u5a92\\u4f53\",\n",
       "                \"\\u7f51\\u7edc\\u5b89\\u5168\",\n",
       "                \"\\u822a\\u5929\",\n",
       "                \"\\u8f6f\\u4ef6\\u670d\\u52a1\",\n",
       "                \"\\u91d1\\u878d\\u79d1\\u6280\",\n",
       "                \"\\u98df\\u54c1\\u996e\\u6599\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"text\": \"Pie-\\u8bbe\\u7f6e\\u989c\\u8272\",\n",
       "            \"target\": \"blank\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_dbecc1bd791442dfa553dbc185206b13.setOption(option_dbecc1bd791442dfa553dbc185206b13);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1e79ce6c6a0>"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Pie\n",
    "from pyecharts.faker import Faker\n",
    "\n",
    "c = (\n",
    "    Pie()\n",
    "    .add(\"\", [list(z) for z in zip(行业, 中国)])\n",
    "    .set_colors([\"blue\", \"green\", \"yellow\", \"red\", \"pink\", \"orange\", \"purple\"])\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"Pie-设置颜色\"))\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {c}\"))\n",
    "    #.render(\"pie_set_color.html\")\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "735a7fde",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['中国', '以色列', '印度', '印度尼西亚', '土耳其', '墨西哥', '巴哈马', '德国', '澳大利亚', '瑞典',\n",
       "       '瑞士', '美国', '英国', '越南', '韩国', '马耳他'],\n",
       "      dtype='object', name='国家')"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_hurun_pivot.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "b1ef2e0e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[570.0,\n",
       "  515.0,\n",
       "  740.0,\n",
       "  1040.0,\n",
       "  965.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  535.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  2000.0,\n",
       "  670.0,\n",
       "  600.0,\n",
       "  670.0,\n",
       "  1200.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  1800.0,\n",
       "  nan,\n",
       "  4000.0,\n",
       "  13400.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  1300.0,\n",
       "  8000.0,\n",
       "  1000.0],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  535.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  480.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  720.0,\n",
       "  1500.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  535.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  700.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  1300.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  800.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  580.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  1300.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  555.0,\n",
       "  nan,\n",
       "  nan],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  1750.0,\n",
       "  nan,\n",
       "  nan],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  800.0,\n",
       "  1300.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  575.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan],\n",
       " [870.0,\n",
       "  1170.0,\n",
       "  nan,\n",
       "  840.0,\n",
       "  1000.0,\n",
       "  575.0,\n",
       "  760.0,\n",
       "  2500.0,\n",
       "  1320.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  575.0,\n",
       "  nan,\n",
       "  600.0,\n",
       "  1200.0,\n",
       "  800.0,\n",
       "  840.0,\n",
       "  1000.0,\n",
       "  600.0,\n",
       "  8400.0,\n",
       "  750.0,\n",
       "  4100.0,\n",
       "  470.0],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  700.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  570.0,\n",
       "  1900.0,\n",
       "  nan],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  550.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  535.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  560.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan],\n",
       " [nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  3000.0,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan,\n",
       "  nan]]"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "国家数据 = []\n",
    "for i in df_hurun_pivot.index:\n",
    "    国家数据.append(df_hurun_pivot.query('国家 == \"{country}\"'.format(country=i)).values[0].tolist())\n",
    "国家数据"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "04cb166c",
   "metadata": {},
   "source": [
    "## 批量化产出可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "6cb41ef7",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Pie\n",
    "\n",
    "\n",
    "for i in range(len(df_hurun_pivot.index)): # for循环每个国家数据\n",
    "    x_data = 行业\n",
    "    y_data = 国家数据[i]\n",
    "    data_pair = [list(z) for z in zip(x_data, y_data)]\n",
    "    data_pair.sort(key=lambda x: x[1])\n",
    "\n",
    "    (\n",
    "        Pie(init_opts=opts.InitOpts(bg_color=\"#2c343c\"))\n",
    "        .add(\n",
    "            series_name=\"访问来源\",\n",
    "            data_pair=data_pair,\n",
    "            rosetype=\"radius\",\n",
    "            radius=\"55%\",\n",
    "            center=[\"50%\", \"50%\"],\n",
    "            label_opts=opts.LabelOpts(is_show=False, position=\"center\"),\n",
    "        )\n",
    "        .set_global_opts(\n",
    "            title_opts=opts.TitleOpts(\n",
    "                title=\"Customized Pie\",\n",
    "                pos_left=\"center\",\n",
    "                pos_top=\"20\",\n",
    "                title_textstyle_opts=opts.TextStyleOpts(color=\"#fff\"),\n",
    "            ),\n",
    "            legend_opts=opts.LegendOpts(is_show=False),\n",
    "        )\n",
    "        .set_series_opts(\n",
    "            tooltip_opts=opts.TooltipOpts(\n",
    "                trigger=\"item\", formatter=\"{a} <br/>{b}: {c} ({d}%)\"\n",
    "            ),\n",
    "            label_opts=opts.LabelOpts(color=\"rgba(255, 255, 255, 0.3)\"),\n",
    "        )\n",
    "        # 修改.render(\"customized_pie.html\") 否则只会生成最后一个国家的数据图表\n",
    "        .render(\"output/\"+df_hurun_pivot.index[i]+\"_customized_pie.html\") #在outpu文件夹生成对应国家名的数据\n",
    "    )\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5d27c06a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
